package com.lekang.le.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lekang.common.annotation.Log;
import com.lekang.common.core.controller.BaseController;
import com.lekang.common.core.domain.AjaxResult;
import com.lekang.common.enums.BusinessType;
import com.lekang.le.domain.CheckOutManagement;
import com.lekang.le.service.ICheckOutManagementService;
import com.lekang.common.utils.poi.ExcelUtil;
import com.lekang.common.core.page.TableDataInfo;

/**
 * 退住办理Controller
 * 
 * @author caoyangyang
 * @date 2025-10-14
 */
@RestController
@RequestMapping("/le/checkoutmanagement")
public class CheckOutManagementController extends BaseController
{
    @Autowired
    private ICheckOutManagementService checkOutManagementService;

    /**
     * 查询退住办理列表
     */
    @PreAuthorize("@ss.hasPermi('le:checkoutmanagement:list')")
    @GetMapping("/list")
    public TableDataInfo list(CheckOutManagement checkOutManagement)
    {
        startPage();
        List<CheckOutManagement> list = checkOutManagementService.selectCheckOutManagementList(checkOutManagement);
        return getDataTable(list);
    }

    /**
     * 导出退住办理列表
     */
    @PreAuthorize("@ss.hasPermi('le:checkoutmanagement:export')")
    @Log(title = "退住办理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CheckOutManagement checkOutManagement)
    {
        List<CheckOutManagement> list = checkOutManagementService.selectCheckOutManagementList(checkOutManagement);
        ExcelUtil<CheckOutManagement> util = new ExcelUtil<CheckOutManagement>(CheckOutManagement.class);
        util.exportExcel(response, list, "退住办理数据");
    }

    /**
     * 获取退住办理详细信息
     */
    @PreAuthorize("@ss.hasPermi('le:checkoutmanagement:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(checkOutManagementService.selectCheckOutManagementById(id));
    }

    /**
     * 新增退住办理
     */
    @PreAuthorize("@ss.hasPermi('le:checkoutmanagement:add')")
    @Log(title = "退住办理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CheckOutManagement checkOutManagement)
    {
        return AjaxResult.success(checkOutManagementService.insertCheckOutManagement(checkOutManagement));
    }

    /**
     * 修改退住办理
     */
    @PreAuthorize("@ss.hasPermi('le:checkoutmanagement:edit')")
    @Log(title = "退住办理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CheckOutManagement checkOutManagement)
    {
        return toAjax(checkOutManagementService.updateCheckOutManagement(checkOutManagement));
    }

    /**
     * 删除退住办理
     */
    @PreAuthorize("@ss.hasPermi('le:checkoutmanagement:remove')")
    @Log(title = "退住办理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(checkOutManagementService.deleteCheckOutManagementByIds(ids));
    }
}
